<template>
  <div class="headerMain">
    <div class="headerBox">
      <div class="loginImg">
        <img :src="require('@/assets/home/logo.png')" alt="" width="160" height="64" />
      </div>
      <ul class="navList">
        <li v-for="(item, index) in navList" :key="index" @mouseover="mouseClick(index)">
          <p :class="[index == currentIndex ? 'activeStyle' : '']">{{ item.name }}</p>
          <div class="showMenuList">
            <ul class="showMenu">
              <li v-for="(subitem, index) in item.subMenuItems" :key="index">
                <!-- 标题 -->
                <div class="subItem">{{ subitem.name }}</div>
                <div class="proMain">
                  <div class="subProductList">
                    <!-- 产品 -->
                    <div class="itempro w1200">
                      <div class="itemInfo" v-for="(productItem, index) in subitem.productList">
                        <img :src="productItem.imgUrl" alt="" width="140" height="140" />
                        <div class="itemText">
                          <p>{{ productItem.title }}</p>
                          <p>{{ productItem.name }}</p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </li>
              <!-- <div class="finAll">
                <button>查看全部</button>
              </div> -->
            </ul>
          </div>
        </li>
      </ul>
    </div>
    <div class="loginStatus">
      <i class="el-icon-user"></i>
      <span>平台登录</span>
    </div>
  </div>
</template>
<script>
import { reactive, toRefs } from 'vue'
export default {
  components: {},
  setup() {
    const state = reactive({
      currentIndex: '0',
      navList: [
        {
          name: '首页',
          path: '/',
        },
        {
          name: '产品中心',
          path: '/productCenter',
          subShow: false,
          subMenuItems: [
            {
              name: '家庭养老床位产品系列',
              Cid: 1,
              productList: [
                {
                  name: '居家安全警报器',
                  title: 'HA01',
                  imgUrl: require('@/assets/home/YLXL01.png'),
                },
                {
                  name: '居家安全警报器',
                  title: 'HA01',
                  imgUrl: require('@/assets/home/YLXL01.png'),
                },
                {
                  name: '居家安全警报器',
                  title: 'HA01',
                  imgUrl: require('@/assets/home/YLXL01.png'),
                },
                {
                  name: '居家安全警报器',
                  title: 'HA01',
                  imgUrl: require('@/assets/home/YLXL01.png'),
                },
                {
                  name: '居家安全警报器',
                  title: 'HA01',
                  imgUrl: require('@/assets/home/YLXL01.png'),
                },
              ],
            },
            {
              name: '智能穿戴系列',
              Cid: 2,
            },
            {
              name: '居家安全报警系列',
              Cid: 3,
            },
            {
              name: '夜间风险防控系列',
              Cid: 4,
            },
            {
              name: '健康医疗监测系列',
              Cid: 5,
            },
          ],
        },
        {
          name: '解决方案',
          path: '/',
        },
        {
          name: '案例中心',
          path: '/',
        },
        {
          name: '关于我们',
          path: '/',
        },
        {
          name: '服务与支持',
          path: '/',
        },
        {
          name: '线上商城',
          path: '/',
        },
      ],
    })
    const mouseClick = (index) => {
      state.currentIndex = index
    }
    return {
      ...toRefs(state),
      mouseClick,
    }
  },
}
</script>
<style scoped lang="less">
.headerMain {
  display: flex;
  height: 64px;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  background: #fff;
  position: fixed;
  box-shadow: rgb(169 169 171) 1px 5px 15px -5px;
  top: 0;
  z-index: 999;
  .headerBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .navList {
    display: flex;
    justify-content: space-between;
    height: 64px;
    > li {
      margin: 0 15px;
      line-height: 64px;
      // position: relative;
      > p {
        font-size: 14px;
        color: #333;
      }
      .activeStyle {
        color: #e4393c;
      }
      .showMenuList {
        width: 100%;
        position: absolute;
        z-index: 99999999;
        position: absolute;
        left: 0;
        top: 60px;
        width: 100%;
        background: #fff;
        // display: none;
        border-bottom: 2px solid #f5f5f5;
        color: #f00;
        .showMenu {
          margin: 0 auto;
          width: 1200px;
          height: 100%;
          display: flex;
          justify-content: space-between;
          .subItem {
            font-size: 14px;
            color: #333;
          }
          // 产品
          .proMain {
            width: 100%;
            height: 280px;
            .subProductList {
              display: flex;
              width: 100%;
              position: absolute;
              left: 0;
              right: 0;
              background: #fff;
              .itempro {
                display: flex;
                justify-content: space-between;
                .itemInfo {
                  background: #f2f2f2;
                  padding: 12px;
                  border-radius: 8px;
                  > img {
                    margin-top: 20px;
                    display: block;
                  }
                  .itemText {
                    height: 60px;
                    > p {
                      line-height: 20px;
                      height: 20px;
                    }
                  }
                }
                .finAll {
                  padding: 15px 20px;
                  color: #333;
                  background: #ddd;
                }
              }
            }
          }
        }
      }
    }
  }
}
</style>
